﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;

namespace HslCommunication.Controls
{
	/// <summary>
	/// 信号灯的控件类
	/// </summary>
	// Token: 0x02000176 RID: 374
	public class UserLantern : UserControl
	{
		/// <summary>
		/// 实例化一个信号灯控件的对象
		/// </summary>
		// Token: 0x06001EDF RID: 7903 RVA: 0x000956B8 File Offset: 0x000938B8
		public UserLantern()
		{
			this.InitializeComponent();
			this.DoubleBuffered = true;
			this.brush_lantern_background = new SolidBrush(this.color_lantern_background);
			this.pen_lantern_background = new Pen(this.color_lantern_background, 2f);
		}

		// Token: 0x06001EE0 RID: 7904 RVA: 0x00009AA1 File Offset: 0x00007CA1
		private void UserLantern_Load(object sender, EventArgs e)
		{
		}

		// Token: 0x06001EE1 RID: 7905 RVA: 0x00095724 File Offset: 0x00093924
		private void UserLantern_Paint(object sender, PaintEventArgs e)
		{
			bool flag = !Authorization.nzugaydgwadawdibbas();
			if (!flag)
			{
				e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
				e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
				Point centerPoint = this.GetCenterPoint();
				e.Graphics.TranslateTransform((float)centerPoint.X, (float)centerPoint.Y);
				int num = centerPoint.X - 5;
				bool flag2 = num < 5;
				if (!flag2)
				{
					Rectangle rect = new Rectangle(-num - 4, -num - 4, 2 * num + 8, 2 * num + 8);
					Rectangle rect2 = new Rectangle(-num, -num, 2 * num, 2 * num);
					e.Graphics.DrawEllipse(this.pen_lantern_background, rect);
					e.Graphics.FillEllipse(this.brush_lantern_background, rect2);
				}
			}
		}

		/// <summary>
		/// 获取或设置开关按钮的背景色
		/// </summary>
		// Token: 0x17000660 RID: 1632
		// (get) Token: 0x06001EE2 RID: 7906 RVA: 0x000957E8 File Offset: 0x000939E8
		// (set) Token: 0x06001EE3 RID: 7907 RVA: 0x00095800 File Offset: 0x00093A00
		[Browsable(true)]
		[Description("获取或设置信号灯的背景色")]
		[Category("外观")]
		[DefaultValue(typeof(Color), "LimeGreen")]
		public Color LanternBackground
		{
			get
			{
				return this.color_lantern_background;
			}
			set
			{
				this.color_lantern_background = value;
				Brush brush = this.brush_lantern_background;
				if (brush != null)
				{
					brush.Dispose();
				}
				Pen pen = this.pen_lantern_background;
				if (pen != null)
				{
					pen.Dispose();
				}
				this.brush_lantern_background = new SolidBrush(this.color_lantern_background);
				this.pen_lantern_background = new Pen(this.color_lantern_background, 2f);
				base.Invalidate();
			}
		}

		// Token: 0x06001EE4 RID: 7908 RVA: 0x00095868 File Offset: 0x00093A68
		private Point GetCenterPoint()
		{
			bool flag = base.Height > base.Width;
			Point result;
			if (flag)
			{
				result = new Point((base.Width - 1) / 2, (base.Width - 1) / 2);
			}
			else
			{
				result = new Point((base.Height - 1) / 2, (base.Height - 1) / 2);
			}
			return result;
		}

		/// <summary> 
		/// 清理所有正在使用的资源。
		/// </summary>
		/// <param name="disposing">如果应释放托管资源，为 true；否则为 false。</param>
		// Token: 0x06001EE5 RID: 7909 RVA: 0x000958C4 File Offset: 0x00093AC4
		protected override void Dispose(bool disposing)
		{
			bool flag = disposing && this.components != null;
			if (flag)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}

		/// <summary> 
		/// 设计器支持所需的方法 - 不要修改
		/// 使用代码编辑器修改此方法的内容。
		/// </summary>
		// Token: 0x06001EE6 RID: 7910 RVA: 0x000958FC File Offset: 0x00093AFC
		private void InitializeComponent()
		{
			base.SuspendLayout();
			base.AutoScaleDimensions = new SizeF(6f, 12f);
			base.AutoScaleMode = AutoScaleMode.Font;
			this.BackColor = Color.Transparent;
			base.Name = "UserLantern";
			base.Load += this.UserLantern_Load;
			base.Paint += this.UserLantern_Paint;
			base.ResumeLayout(false);
		}

		// Token: 0x040006FF RID: 1791
		private Color color_lantern_background = Color.LimeGreen;

		// Token: 0x04000700 RID: 1792
		private Brush brush_lantern_background = null;

		// Token: 0x04000701 RID: 1793
		private Pen pen_lantern_background = null;

		/// <summary> 
		/// 必需的设计器变量。
		/// </summary>
		// Token: 0x04000702 RID: 1794
		private IContainer components = null;
	}
}
